package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dao.PmsProductDao;
import com.macro.mall.service.PmsProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;

@Controller
@Api(tags = "HomeController", description = "后台首页")
@RequestMapping("/home")
@ResponseBody
public class HomeController {
    @Autowired
    private PmsProductDao pmsProductDao;

    @ApiOperation("查询首页数据：今日上传商品数")
    @RequestMapping(value = "/data", method = RequestMethod.GET)
    public CommonResult productCountByDate() {
        HashMap<String, Object> map = new HashMap<>();
        Integer orderCount = pmsProductDao.orderCountByDate();
        Integer productCount = pmsProductDao.productCountByDate();
        Integer userCount = pmsProductDao.userCountByDate();
        Integer newProductCount = pmsProductDao.newProductCountByDate();
        map.put("orderCount",orderCount);
        map.put("productCount",productCount);
        map.put("newProductCount",newProductCount);
        map.put("userCount",userCount);
        return CommonResult.success(map);
    }
}
